/*
 * All rights Reserved, Designed By DataDriver
 * Copyright:    DataDriver.Inc
 * Company:      Zhuo Wo Infomation Technology (ShangHai) CO.LTD
 */
package com.sun;

import com.sun.aop.MathCalculater;
import com.sun.config.AopConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MainTest {


    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
        String[] names = context.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }

        //分析：由于这个对象是自己创建当然不会生效，要使对象生效，应该使用Spring容器中的MathCalculater
//        MathCalculater mathCalculater = new MathCalculater();
//        int i = mathCalculater.div(8, 4);

        MathCalculater bean = context.getBean(MathCalculater.class);
        //int i = bean.div(8, 2);
        int i = bean.div(1, 0);
        System.out.println(i);
    }
}
